<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/4/7
  Time: 20:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

    <%
        List<String> chatList = (List<String>) application.getAttribute("chat");
        if (chatList == null){
            chatList = new ArrayList<String>();
        }
        String txt = request.getParameter("txt");
        if (txt != null){
            chatList.add(txt);
        }
        application.setAttribute("chat",chatList);
    %>


    <div style="height: 500px;overflow: scroll;border: 1px solid aqua">
        <ul>
            <%
                for (String s : chatList) {
            %>
            <li> <%=s%></li>
            <%
                }
            %>
        </ul>
    </div>


    <form action="chitchat.jsp" method="get">
        请输入：<input type="text" id="txt" name="txt"><input type="submit" value="确定">
    </form>


<%
    Object visit = application.getAttribute("visit");
    if (visit == null){
        visit = 1;
    }else{
        visit = (Integer)visit + 1;
    }
    application.setAttribute("visit",visit);
%>
<div>本页面被加载了<%=visit%></div>
</body>
</html>
